# _*_ coding : utf-8 _*_
# @Time : 2022/1/13 0013 10:37
# @Author : 02.requests实战之网页采集器
# @Project : 小猿圈爬虫

import requests
if __name__ == '__main__':
    # UA伪装：将对应的User-Agent封装到一个字典中
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36'
    }
    #step1 指定url
    #url = 'https://www.sogou.com/web?query=波晓张'
    url = 'https://www.sogou.com/web'
    #处理url携带的参数：封装到字典中
    kw = input('enter a word:')
    param = {
        'query' : kw
    }
    #step2 发起请求
    response = requests.get(url=url,params=param,headers=headers)

    page_text = response.text

    fileName = kw+'.html'
    with open(fileName,'w',encoding='utf-8') as fp:
        fp.write(page_text)
    print(fileName,'保持成功！！！')